package com.ssy.lingxi.contract.controller;


import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.contract.model.vo.sign.request.*;
import com.ssy.lingxi.contract.model.vo.sign.response.FaceVerifyResponse;
import com.ssy.lingxi.contract.model.vo.sign.response.SignatureApplyResponse;
import com.ssy.lingxi.contract.model.vo.sign.response.SignatureAuthResponse;
import com.ssy.lingxi.contract.model.vo.sign.response.SignatureAuthStateResponse;
import com.ssy.lingxi.contract.service.ISignatureAuthService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * @menu 合同能力 - 电子签章 - 电子签章申请
 * @author yzc
 * @version 2.0.0
 * @date 2020/9/1
 *
 */
@RestController
@RequestMapping("/contract/signatureAuth")
public class SignatureAuthController extends BaseController {

    @Resource
    private ISignatureAuthService signatureAuthService;

    /**
     * 电子签章认证查询
     * @return 返回结果
     */
    @GetMapping(value = "/get")
    public Wrapper<SignatureAuthResponse> getSignatureDetail() {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.getSignatureDetail(sysUser);
    }

    /**
     * 电子签章查询认证状态
     * @return 返回结果
     */
    @GetMapping(value = "/authState")
    public Wrapper<SignatureAuthStateResponse> getAuthState() {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.getAuthState(sysUser);
    }

    /**
     * 电子签章认证申请
     * @return 返回结果
     */
    @PostMapping(value = "/apply")
    public Wrapper<SignatureApplyResponse> signatureApply() {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.signatureApply(sysUser);
    }

    /**
     * 法人认证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/legalRepAuth")
    public Wrapper<Void> legalRepAuth(@RequestBody @Validated LegalRepAuthAuthRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.legalRepAuth(request, sysUser);
    }

    /**
     * 经办人认证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/agentAuth")
    public Wrapper<Void> agentAuth(@RequestBody @Validated AgentAuthRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.agentAuth(request, sysUser);
    }

    /**
     * 个人认证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/personalAuth")
    public Wrapper<Void> personalAuth(@RequestBody @Validated PersonalAuthRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.personalAuth(request, sysUser);
    }

    /**
     * 发起对公打款验证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/paymentVerify")
    public Wrapper<Void> paymentVerify(@RequestBody @Validated PaymentVerifyCreateRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.paymentVerifyCreate(request, sysUser);
    }

    /**
     * 对公打款金额校验
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/paymentVerifyAmount")
    public Wrapper<FaceVerifyResponse> paymentVerifyAmount(@RequestBody @Validated PaymentVerifyAmountRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.paymentVerifyAmount(request, sysUser);
    }

    /**
     * 发起授权签署实名认证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/legalRepSignVerify")
    public Wrapper<Void> legalRepSignVerify(@RequestBody @Validated LegalRepSignVerifyRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.legalRepSignVerify(request, sysUser);
    }

    /**
     * 发起支付宝认证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/faceVerify")
    public Wrapper<FaceVerifyResponse> faceVerify(@RequestBody @Validated FaceVerifyRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.faceVerify(request, sysUser);
    }

    /**
     * 发起手机认证
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/mobileVerify")
    public Wrapper<Void> mobileVerify(@RequestBody @Validated MobileVerifyRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.mobileVerify(request, sysUser);
    }

    /**
     * 手机认证验证码校验
     * @param request 请求参数
     * @return 返回结果
     */
    @PostMapping(value = "/mobileVerifyCode")
    public Wrapper<Void> mobileVerifyCode(@RequestBody @Validated MobileVerifyCodeRequest request) {
        UserLoginCacheDTO sysUser = getSysUser();
        return signatureAuthService.mobileVerifyCode(request, sysUser);
    }
}
